package com.primaryedu.ui.app.nicedialog;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.primaryedu.R;
import com.primaryedu.utils.Logger;

/**
 * Created by Administrator on 2018/9/12.
 */

public class MyCustomDialog extends BaseNiceDialog {
    private String type;

    public static MyCustomDialog newInstance(String type) {
        Bundle bundle = new Bundle();
        bundle.putString("type", type);
        MyCustomDialog dialog = new MyCustomDialog();
        dialog.setArguments(bundle);
        return dialog;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle bundle = getArguments();
        if (bundle == null) {
            return;
        }
        type = bundle.getString("type");
    }

    @Override
    public int intLayoutId() {
        return R.layout.customdialog_layout;
    }

    @Override
    public void convertView(ViewHolder holder, final BaseNiceDialog dialog) {
        if ("backAccout".equals(type)) {
            holder.setText(R.id.title, "提示");
            holder.setText(R.id.message, "是否确认退出账号？");
        } else if ("clearchche".equals(type)) {
            holder.setText(R.id.title, "清除缓存");
            holder.setText(R.id.message, "清除缓存会导致下载的内容删除，是否确定?");
        }else if ("saveAdvice".equals(type)){
            holder.setText(R.id.title, "提示");
            holder.setText(R.id.message, "是否确认提交意见反馈？");
        }else if ("messageboard".equals(type)){
            holder.setText(R.id.title, "提示");
            holder.setText(R.id.message, "是否确认发布留言？");
        }else if ("deletedynamic".equals(type)){
            holder.setText(R.id.title, "提示");
            holder.setText(R.id.message, "是否确认删除动态？");
        }else if ("deleteclassdynamic".equals(type)){
            holder.setText(R.id.title, "提示");
            holder.setText(R.id.message, "是否确认删除动态？");
        }
        holder.setOnClickListener(R.id.cancel, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        Logger.withTag("yy").log("type====" + type);
        holder.setOnClickListener(R.id.ok, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                dialog.dismiss();
//                if (type.equals("backAccout")) {
//                    DialogCallBackUtils.doCallBackMethod(type, dialog);
//                } else if (type.equals("clearchche")) {
//                    DialogCallBackUtils.doCallBackChche(type, dialog);
//                }else if(type.equals("saveAdvice")){
                    DialogCallBackUtils.doCallBackMethod(type, dialog);
//                }
            }
        });
    }
}
